#ifndef G2D_H
#define G2D_H

#include "Graphics.h"
#include "SDL.h"
#include "SDL_image.h"
#include "SDL_ttf.h"
#include <string>

#define FLIP_VERTICAL 1
#define FLIP_HORIZONTAL 2

class G2D:public Graphics
{
public:
	/*
	 * Constructor
	 */
	G2D();

	/*
	 * Utility
	 */
	SDL_Rect convertQuad(Quad q);

	/*
	 * Getter methods
	 */
	SDL_Surface* getScreen();
	SDL_Surface* getText();

	/*
	 * Image Loading
	 */
	SDL_Surface *loadImage(std::string filename);

	/*
	 * Image Displaying
	 */
	void applySurface(int x, int y, SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip);
	void applyScreen(int x, int y, SDL_Surface* source, SDL_Rect* clip);

	/*
	 * Image Editing
	 */
	void setColorKeyT(SDL_Surface *surface, Uint32 pixel);
	Uint32 getPixel(SDL_Surface *surface, int x, int y);
	/*
	 * setPixel is very powerful and dangerous, use with caution
	 */
	void setPixel(SDL_Surface *surface, int x, int y, Uint32 pixel);
	SDL_Surface* flipImage(SDL_Surface *source, int flags);

	/*
	 * Text
	 */
	void printScreen(SDL_Surface *screen, float x, float y, std::string s);
	void setFont(std::string filename, int fontsize);

	/*
	 * Drawing Functionality
	 */
	void drawRect(int x, int y, int w, int h, Uint32 color);
	void drawRect(SDL_Rect rect, Uint32 color);

	/*
	 * Color
	 */
	Uint32 getColor(Uint8 r, Uint8 g, Uint8 b);

private:
	SDL_Surface* screen;
	SDL_Surface* text;
	TTF_Font* font;
};

#endif /* GSDL_H */
